package com.mszlu.blog.controller;

import com.mszlu.blog.service.CommentsService;
import com.mszlu.blog.vo.Result;
import com.mszlu.blog.vo.params.CommentsParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("comments")
public class CommentsController {
    @Autowired
    private CommentsService commentsService;
    /**
     * 根据文章id查找评论
     * @param id
     * @return
     */
    @GetMapping("article/{id}")
    public Result comments(@PathVariable("id") Long id){
        return commentsService.findCommentsByArticleId(id);
    }

    @PostMapping("create/change")
    public Result changeComments(@RequestBody CommentsParams commentsParams){
        return commentsService.addComment(commentsParams);
    }
}
